package com.jz.netthings.bloodsources.controller;


import com.jz.netthings.bloodsources.bean.XyLink;
import com.jz.netthings.bloodsources.bean.XyLinkNurseUpdateList;
import com.jz.netthings.bloodsources.service.XyLinkNurseUpdateListService;
import com.jz.netthings.bloodsources.service.XyLinkService;
import com.jz.netthings.exception.AdscmSystemException;
import com.jz.netthings.security.utils.Token;
import com.jz.netthings.support.SimpleCoreResponse;
import com.jz.netthings.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.SimpleDateFormat;

/**
 * <p>
 * 血源链接护士修改配置清单记录表 前端控制器
 * </p>
 *
 * @author 张凡
 * @since 2019-08-03
 */
@RestController
@RequestMapping("/adscm/bloodSources/xyLinkNurseUpdateList")
public class XyLinkNurseUpdateListController {
    @Autowired
    XyLinkNurseUpdateListService xyLinkNurseUpdateListService;
    @Autowired
    RedisTemplate<Object, Token> tokenRedisTemplate;
    SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    @RequestMapping("/queryByCondition")
    public SimpleCoreResponse queryByCondition(
            String linkId,
            String currentPage,
            String pageSize
    ) throws AdscmSystemException {
        return new SimpleCoreResponse("200","查询成功",xyLinkNurseUpdateListService.queryByCondition(linkId,currentPage,pageSize));
    }
    @RequestMapping("/insertXyLinkNurseUpdateListInfo")
    public SimpleCoreResponse insertXyLinkNurseUpdateListInfo(@RequestBody XyLinkNurseUpdateList xyLinkNurseUpdateList, HttpServletRequest request) throws AdscmSystemException, IOException {
        String tokenId = request.getParameter("tokenId");
        Token token = AdscmBaseUtils.getInstance().getTokenByTokenId(tokenId, tokenRedisTemplate);
        Boolean result= xyLinkNurseUpdateListService.insertXyLinkNurseUpdateListInfo(xyLinkNurseUpdateList ,token);
        return new SimpleCoreResponse("200","查询成功" ,result);
    }
}

